<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/28
 * Time: 17:19
 */
namespace App\Http\Controllers\Home;
use App\Http\Controllers\Controller;

class DetailController extends Controller
{
    public function index()
    {
//        $surl="/api/master/getSecID.json?field=&ticker=600807&partyID=&assetClass=E";
//        $secID=self::http_get($surl);
//        var_dump($secID);
//        exit;
        $url="https://api.wmcloud.com/data/v1/api/market/getMktEqud.json?field=&beginDate=&endDate=&secID=&ticker=&tradeDate=20161128";
        $a=$this->http_get($url);
        echo $a;
        exit;
    }

    private static function http_request($url,$data)
    {
        //开启一个curl会话,返回一个CURL句柄$curl
        $curl=curl_init();
        //设置请求的url
        curl_setopt($curl,CURLOPT_URL,$url);
        //curl_setopt($curl, CURLOPT_PORT,10110);
//    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        curl_setopt($curl,CURLOPT_POST,1);
        //传递参数
        curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
        curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
        $result=curl_exec($curl);
        //返回最后一次cURL操作的错误号
        $error=curl_error($curl);
        if($error){
            $info=curl_getinfo($curl);
            var_dump($info);
            var_dump($error);
        }
        //关闭CURL请求
        curl_close($curl);
        return $result;
    }

    public function http_get($url){
        $ch = curl_init();

        //设置选项，包括URL
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);

        //执行并获取HTML文档内容
        $output = curl_exec($ch);
        $error=curl_error($ch);
        if($error){
            $info=curl_getinfo($ch);
            var_dump($info);
            var_dump($error);
        }

        //释放curl句柄
        curl_close($ch);

        //打印获得的数据
        return $output;
    }
}